import requests
from urllib.parse import urlparse
import re
import csv
f = open('data_api.csv', mode='w', newline='')
csvwrter = csv.writer(f)
with open(f'active_apis_data.txt', encoding='utf-8') as file:
    content = file.read()
obj = re.compile(r'.*?"url": "(?P<name>.*?)",.*?"style": "(?P<style>.*?)",.*?', re.S)
result = obj.finditer(content)
for it in result:
    print(it.group("name"), '\t')
    print(it.group("style"), '\t')
    data = [it.group("name")[:-2], it.group("style")]
    csvwrter.writerow(data)
f.close()
